/* GUI CONVERTED from sosorp12.p (converter v1.75) Fri Feb  2 01:27:16 2001 */
/* sosorp12.p - -SHIPMENT summary BY CUSTOMER                                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* web convert sosorp12.p (converter v1.00) Tue Sep 30 12:00:06 1997 */
/* web tag in sosorp12.p (converter v1.00) Mon Sep 29 14:35:40 1997 */
/*F0PN*/ /*K0L6*/
/*V8:ConvertMode=FullGUIReport                                       */
/* REVISION: 1.0           LAST EDIT: 06/25/87         MODIFIED BY: pml       */
/* REVISION: 2.0           LAST EDIT: 01/06/88                  BY: pml A125  */
/* REVISION: 4.0           LAST MODIFIED: 02/24/88              BY: WUG *A175**/
/* REVISION: 4.0           LAST MODIFIED: 09/20/88              BY: WUG *A442**/
/* REVISION: 4.0           LAST MODIFIED: 02/08/89              BY: JLC *C0028*/
/* REVISION: 4.0           LAST MODIFIED: 12/08/89              BY: ftb *B418*/
/* REVISION: 6.0           LAST MODIFIED: 10/19/90              BY: afs *D112**/
/* REVISION: 7.2           LAST MODIFIED: 10/18/94              BY: jzs *FS87**/
/* REVISION: 7.3           LAST MODIFIED: 04/10/96              BY: jzw *G1P6**/
/* REVISION: 8.6           LAST MODIFIED: 10/04/97              BY: mur *K0L6**/
/* REVISION: 8.6E          LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E          LAST MODIFIED: 07/05/98   BY: *L024* Sami Kureishy*/
/* REVISION: 8.6E          LAST MODIFIED: 08/12/99   BY: *L0GK* Santosh Rao  */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 07/03/00 BY: *N0DX* Mudit Mehta      */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KN* myb                  */
/* REVISION: 9.1      LAST MODIFIED: 08/24/00 BY: *N0NM* Arul Victoria   */
/* REVISION: 9.1      LAST MODIFIED: 10/13/00 BY: *N0WC* Mudit Mehta          */


/*GUI global preprocessor directive settings */
&GLOBAL-DEFINE PP_PGM_RP TRUE
&GLOBAL-DEFINE PP_ENV_GUI TRUE


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/*FS87*/ {mfdtitle.i "b+ "}
/*N0WC*/ {cxcustom.i "SOSORP12.P"}

         /* ********** Begin Translatable Strings Definitions ********* */

         &SCOPED-DEFINE sosorp12_p_1 "Round to Thousands"
         /* MaxLen: Comment: */

         &SCOPED-DEFINE sosorp12_p_5 "Per Column"
         /* MaxLen: Comment: */

         &SCOPED-DEFINE sosorp12_p_6 "Day/Week/Month"
         /* MaxLen: Comment: */

/*N0DX*
 *       &SCOPED-DEFINE sosorp12_p_2 "Sales figures in thousands"
 *       /* MaxLen: Comment: */
 *
 *       &SCOPED-DEFINE sosorp12_p_3 "REPORT TOTALS: "
 *       /* MaxLen: Comment: */
 *
 *       &SCOPED-DEFINE sosorp12_p_4 "Total Sales"
 *       /* MaxLen: Comment: */
 *
 *       &SCOPED-DEFINE sosorp12_p_7 "   Total Qty"
 *       /* MaxLen: Comment: */
 *N0DX*/

         /* ********** End Translatable Strings Definitions ********* */

         define variable start like ro_start.
         define variable ending like ro_end.
         define variable cust like tr_addr.
         define variable cust1 like tr_addr.
         define variable buyer like pt_buyer.
         define variable prod_line like pt_prod_line.
         define variable ptgroup like pt_group.
         define variable part_type like pt_part_type.
         define variable vendor like pt_vend.
         define variable pm_code like pt_pm_code.
         define variable interval as integer extent 14 format "->>>,>>9".
         define variable sdate as date extent 14.
         define variable salesqty as decimal extent 14 format "->>>>>>>9".
         define variable salesdol as decimal extent 14 format "->>>>>>>9".
         define variable due_date like tr_effdate.
         define variable i as integer.
         define variable j as integer.
         define variable dwm as character format "!(1)" label {&sosorp12_p_6}.
         define variable idays as integer format ">>>>>9" label {&sosorp12_p_5}.
         define variable monthend as integer.
         define variable num_intervals as integer initial 13 format "9".
         define variable tot_qty as decimal format "->>>>>>>>9".
         define variable tot_dol as decimal format "->>>>>>>>9".
         define variable first_cust like mfc_logical.
         define variable type like cm_type.
         define variable type1 like cm_type.
         define variable region like cm_region.
         define variable region1 like cm_region.
         define variable slspsn like sp_addr.
         define variable slspsn1 like slspsn.
         define variable base_rpt like so_curr.
/*G1P6*  initial "Base" format "x(4)". */
         define variable base_price like tr_price.
/*D112*/ define variable round_1000 like mfc_logical
          label {&sosorp12_p_1} initial no.
/*L024*/ define variable mc-error-number like msg_nbr no-undo.

/*N0DX*/ define variable disp_char2 as character format "x(45)" no-undo.

/*L024*/ {gprunpdf.i "mcpl" "p"}

         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1.4 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1   COLUMN 3 NO-LABEL
 SKIP(.1)  /*GUI*/
cust           colon 15
            cust1          label {t001.i} colon 49 skip
            type           colon 15
            type1          label {t001.i} colon 49 skip
            region         colon 15
            region1        label {t001.i} colon 49 skip
            slspsn         colon 15
            slspsn1        label {t001.i} colon 49 skip (1)
            base_rpt       colon 22
            start          colon 22
            dwm            colon 22
            idays          colon 22
            round_1000     colon 22 skip
          SKIP(.4)  /*GUI*/
with frame a side-labels width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER.
 F-a-title = &IF (DEFINED(SELECTION_CRITERIA) = 0)
  &THEN " Selection Criteria "
  &ELSE {&SELECTION_CRITERIA}
  &ENDIF .
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:WIDTH-PIXELS in frame a =
  FONT-TABLE:GET-TEXT-WIDTH-PIXELS(
  RECT-FRAME-LABEL:SCREEN-VALUE in frame a + " ", RECT-FRAME-LABEL:FONT).
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5. /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

/*K0L6*/ {wbrp01.i}


/*GUI*/ {mfguirpa.i true  "printer" 132 }

/*GUI repeat : */
/*GUI*/ procedure p-enable-ui:

/*FS87 do: */
     if start = ? then start = today - (12 * 7) + 1.
     if ending = ? then ending = today.
     if dwm = "" then dwm = "W".
     if idays = 0 or idays = ? then idays = 1.
     if cust1 = hi_char then cust1 = "".
     if region1 = hi_char then region1 = "".
     if type1 = hi_char then type1 = "".
     if slspsn1 = hi_char then slspsn1 = "".

/*K0L6*/ if c-application-mode <> 'web' then
         
run p-action-fields (input "display").
run p-action-fields (input "enable").
end procedure. /* p-enable-ui, replacement of Data-Entry GUI*/

/*GUI*/ procedure p-report-quote:


/*K0L6*/ {wbrp06.i &command = update &fields = "  cust cust1 type type1 region
region1 slspsn slspsn1 base_rpt start dwm idays round_1000" &frm = "a"}

/*K0L6*/ if (c-application-mode <> 'web') or
/*K0L6*/ (c-application-mode = 'web' and
/*K0L6*/ (c-web-request begins 'data')) then do:

     bcdparm = "".
     {mfquoter.i cust   }
     {mfquoter.i cust1  }
     {mfquoter.i type   }
     {mfquoter.i type1  }
     {mfquoter.i region }
     {mfquoter.i region1}
     {mfquoter.i slspsn }
     {mfquoter.i slspsn1}
     {mfquoter.i base_rpt }
     {mfquoter.i start  }
     {mfquoter.i dwm    }
     {mfquoter.i idays  }
     {mfquoter.i round_1000}

     if cust1 = "" then cust1 = hi_char.
     if region1 = "" then region1 = hi_char.
     if type1 = "" then type1 = hi_char.
     if slspsn1 = "" then slspsn1 = hi_char.

     if index("dwmp",dwm) = 0 then do:
        {mfmsg.i 14 3} /* MUST BE (D)ay (W)eek OR (M)onth Please re-enter*/
/*FS87*/
/*K0L6*/ if c-application-mode = 'web' then return.
else /*GUI NEXT-PROMPT removed */
/*FS87*/    /*GUI UNDO removed */ RETURN ERROR.
     end.

/*K0L6*/ end.
         
/*GUI*/ end procedure. /* p-report-quote */
/*GUI - Field Trigger Section */

/*GUI MFSELxxx removed*/
/*GUI*/ procedure p-report:
/*GUI*/   {gpprtrpa.i  "printer" 132}
/*GUI*/   mainloop: do on error undo, return error on endkey undo, return error:


    {hksimsg.i """" """"}       /*fdn*/

     {mfphead.i}

/*FS87   end. */

   /* COMPUTE START DATES */
   sdate[1] = low_date.
   {mfcsdate.i}

   display

   sdate[2] space(2) sdate[3] space(2)
   sdate[4] space(2) sdate[5] space(2)
   sdate[6] space(2) sdate[7] space(2)
   sdate[8] space(2) sdate[9] space(2)
   sdate[10] space(2) sdate[11] space(2)
   sdate[12] space(2) sdate[13]
/*N0DX*   {&sosorp12_p_7} skip */
/*N0DX*/  getTermLabelRt("TOTAL_QTY",12) format "x(12)" skip

   sdate[3] - 1 space(2) sdate[4] - 1 space(2)
   sdate[5] - 1 space(2) sdate[6] - 1 space(2)
   sdate[7] - 1 space(2) sdate[8] - 1 space(2)
   sdate[9] - 1 space(2) sdate[10] - 1 space(2)
   sdate[11] - 1 space(2) sdate[12] - 1 space(2)
   sdate[13] - 1 space(2) sdate[14] - 1 space(2)
/*N0DX*   {&sosorp12_p_4} skip */
/*N0DX*/  getTermLabel("TOTAL_SALES",12) format "x(12)" skip

   "--------- --------- --------- --------- --------- --------- ---------"
   "--------- --------- --------- --------- --------- -----------" skip
   with frame b no-labels width 132 page-top no-box STREAM-IO /*GUI*/ .

   /*D112*/ FORM /*GUI*/ 
/*N0DX*   {&sosorp12_p_2} */
/*N0DX*/  disp_char2 no-label
   with STREAM-IO /*GUI*/  frame footer page-bottom
/*G1P6*/ width 132.

/*N0NM* ------------------- BEGIN DELETE ----------------------- *
 * /* SET EXTERNAL LABELS */
 * setFrameLabels(frame footer:handle).
 *N0NM* ------------------- END   DELETE ----------------------- */

/*N0DX   if round_1000 then  view frame footer.*/

/*N0DX Start added*/
if round_1000 then do:
   disp_char2:screen-value = getTermLabel("SALES_FIGURES_IN_THOUSANDS", 45).
   view frame footer.
end.
/*N0DX End added*/

   view frame phead.

   for each cm_mstr where (cm_addr >= cust and cm_addr <= cust1)
   and (cm_region >= region and cm_region <= region1)
   and (cm_type >= type and cm_type <= type1)
   and (cm_slspsn[1] >= slspsn and cm_slspsn[1] <= slspsn1) no-lock
   by cm_addr with frame b width 132 no-box:

      /* INITIALIZE VARIABLES */
      do i = 1 to num_intervals + 1:
     salesqty[i] = 0.
     salesdol[i] = 0.
      end.

      /* CALCULATE SHIPMENTS   FOR EACH INTERVAL */
      tot_qty = 0.
      tot_dol = 0.
      first_cust = yes.
/*N0WC*/ {&SOSORP12-P-TAG1}
      for each tr_hist
       where tr_addr = cm_addr
     and (tr_type = "ISS-SO" or tr_type = "RCT-SOR")
     and (tr_effdate >= sdate[2] and tr_effdate < sdate[14])
    AND ( LOOKUP(tr_site,GLOBAL_user_site) > 0)     /*fdn*/
/*G1P6*  and ((base_rpt = "Base") */
/*G1P6*/ and ((base_rpt = "")
     or (tr_curr = base_rpt))
/*N0WC*/ {&SOSORP12-P-TAG2}
       no-lock use-index tr_addr_eff:
     if first_cust then do:
        if page-size - line-counter < 3 then page.
        display
        cm_addr cm_sort skip
        with frame bb no-labels width 132 STREAM-IO /*GUI*/ .
        first_cust = no.
     end.
     base_price = tr_price.
/*G1P6*/ if base_rpt <> ""
         and tr_curr <> base_curr then
/*L0GK*/ do:
/*L024*     base_price = base_price * tr_ex_rate.*/
/*L024*/    {gprunp.i "mcpl" "p" "mc-curr-conv"
                         "(input base_curr,
                           input tr_curr,
                           input tr_ex_rate2,
                           input tr_ex_rate,
                           input base_price,
                           input false,
                           output base_price,
                           output mc-error-number)"}.
/*L0GK*/ end. /* IF BASE_RPT <> "" AND .. */
/*L024*/ if mc-error-number <> 0 then do:
/*L024*/    {mfmsg.i mc-error-number 2}
/*L024*/ end.

     due_date = tr_effdate.
     tot_qty = tot_qty - tr_qty_loc.
     tot_dol = tot_dol - (base_price * tr_qty_loc).
     do i = num_intervals + 1 to 1 by -1:
        if due_date >= sdate[i] then do:
           salesqty[i] = salesqty[i] - tr_qty_loc.
           salesdol[i] = salesdol[i] - (base_price * tr_qty_loc).
           leave.
        end.
     end.
      end.

      /*END SECTION*/

      if not first_cust then do:
     if round_1000 then do:
        do i = 1 to num_intervals + 1:
           salesdol[i] = round(salesdol[i] / 1000, 0).
        end.
        tot_dol = round(tot_dol / 1000, 0).
     end.

     accumulate salesqty(total).
     accumulate salesdol(total).
     accumulate tot_qty(total).
     accumulate tot_dol(total).

     display
      salesqty[2 for 12] tot_qty skip
      salesdol[2 for 12] tot_dol
     with frame cc no-labels width 132 STREAM-IO /*GUI*/ .
      end.

      
/*GUI*/ {mfguirex.i } /*Replace mfrpexit*/

   end.
/*N0DX*   display skip(1) {&sosorp12_p_3} skip */
/*N0DX*/   display skip(1) caps(getTermLabel("REPORT_TOTALS",25)) + ": ":U format "x(27)" skip
   accum total salesqty[2] format "->>>>>>>9"
   accum total salesqty[3] format "->>>>>>>9"
   accum total salesqty[4] format "->>>>>>>9"
   accum total salesqty[5] format "->>>>>>>9"
   accum total salesqty[6] format "->>>>>>>9"
   accum total salesqty[7] format "->>>>>>>9"
   accum total salesqty[8] format "->>>>>>>9"
   accum total salesqty[9] format "->>>>>>>9"
   accum total salesqty[10] format "->>>>>>>9"
   accum total salesqty[11] format "->>>>>>>9"
   accum total salesqty[12] format "->>>>>>>9"
   accum total salesqty[13] format "->>>>>>>9"
   accum total tot_qty format "->>>>>>>>>9" skip

   accum total salesdol[2] format "->>>>>>>9"
   accum total salesdol[3] format "->>>>>>>9"
   accum total salesdol[4] format "->>>>>>>9"
   accum total salesdol[5] format "->>>>>>>9"
   accum total salesdol[6] format "->>>>>>>9"
   accum total salesdol[7] format "->>>>>>>9"
   accum total salesdol[8] format "->>>>>>>9"
   accum total salesdol[9] format "->>>>>>>9"
   accum total salesdol[10] format "->>>>>>>9"
   accum total salesdol[11] format "->>>>>>>9"
   accum total salesdol[12] format "->>>>>>>9"
   accum total salesdol[13] format "->>>>>>>9"
     accum total tot_dol format "->>>>>>>>>9"
   with frame d no-labels width 132 no-box STREAM-IO /*GUI*/ .

   
/*GUI*/ {mfguitrl.i} /*Replace mfrtrail*/

/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

   hide message no-pause.
   {mfmsg.i 9 1}
end.

/*K0L6*/ {wbrp04.i &frame-spec = a}

/*GUI*/ end procedure. /*p-report*/
/*GUI*/ {mfguirpb.i &flds=" cust cust1 type type1 region region1 slspsn slspsn1 base_rpt start dwm idays round_1000 "} /*Drive the Report*/
